from  openpyxl import Workbook
import openpyxl
import os


cfgpath = "errorInfo.xlsx"

def addOneLine(data):
    if os.path.exists(cfgpath):
        wb = openpyxl.load_workbook(cfgpath)
        ws = wb.active
        ws.append(data)
        wb.save(cfgpath)
    else:
        wb = Workbook()
        ws = wb.active
        ws.append(["序列号","MAC","错误项"])
        ws.append(data)
        wb.save(cfgpath)
def addLines(data):
    if os.path.exists(cfgpath):
        wb = openpyxl.load_workbook(cfgpath)
        ws = wb.active
        for c in data:
          ws.append(c)
        wb.save(cfgpath)
    else:
        wb = Workbook()
        ws = wb.active
        ws.append(["序列号","MAC","错误项"])
        for c in data:
            ws.append(c)
        wb.save(cfgpath)

if __name__ == "__main__":
    one = ["sn","mac","4455551"]
    two = ["sn","mac","4455552"]
    data = [one,two]
    print(data)
    addLines(data)

